<script setup lang="ts">
import FinanceLine from '@/components/Echart/line/FinanceLine.vue'
import { reactive, watch, ref, computed } from 'vue'
import { storeToRefs } from 'pinia'
import { useFinanceStore } from '@/stores/module/finance'
import { useDialogStore } from '@/stores/dialog'
const dialogStore = useDialogStore()
const { dialogInfo } = dialogStore
const dialogInfoVisible = dialogInfo.visible
const FinanceStore = useFinanceStore() // 创建store实例
const { getProfitMom } = storeToRefs(FinanceStore)

const options = computed(() => {
  return {
    name: 'ComparisonOfQuarterlyIncreaseInProfitsByRegion',
    xAxis: {
      data: getProfitMom.value?.info[0]?.tableHeadData,
    },
    legend: {
      data: getProfitMom.value?.sub_titles,
    },
    data: getProfitMom.value?.info[0]?.bar?.value,
  }
})

watch(
  () => getProfitMom.value,
  () => {
    options.value.xAxis.data = getProfitMom.value?.info[0]?.tableHeadData
    options.value.legend.data = getProfitMom.value?.sub_titles
    options.value.data = getProfitMom.value?.info[0]?.bar?.value
  },

  { deep: true }
)
</script>
<template>
  <card-box componentName="ComparisonOfQuarterlyIncreaseInProfitsByRegion">
    <template v-slot:title v-if="getProfitMom.titleMount">
      <h1
        :class="{
          subtitle: dialogInfoVisible,
        }"
      >
        {{ getProfitMom.titleMount }}
      </h1>
    </template>

    <FinanceLine :chart-data="options" v-if="getProfitMom.info[0]?.line" />
    <div v-else class="default-img">
      <p>{{ $t('bi_common_nodata') }}</p>
    </div>
  </card-box>
</template>
<style lang="scss" scoped>
.default-img {
  width: 100%;
  text-align: center;
  padding: 120px 0;
  background-image: url('@/assets/images/canvsimage/default.png');
  background-repeat: no-repeat;
  background-position: center;
  font-size: 16px;
  color: #00f6ff;
}

.my-btn {
  width: 100px;
  height: 25px;
  text-align: center;
  float: right;
  margin-top: -30px;
  font-size: 10px;
  background-color: rgba(0, 53, 171, 0.8);
  border: 1px solid #0b45ca;
  color: #00f6ff;
  cursor: pointer;
}
.dialog-fade-enter-active .el-dialog.transactionData {
  animation: tilt-in-left 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

@keyframes tilt-in-left {
  0% {
    -webkit-transform: rotateX(-30deg) translateX(-300px) skewX(-30deg);
    transform: rotateX(-30deg) translateX(-300px) skewX(-30deg);
    opacity: 0;
  }
  100% {
    -webkit-transform: rotateX(0deg) translateX(0) skewX(0deg);
    transform: rotateX(0deg) translateX(0) skewX(0deg);
    opacity: 1;
  }
}
.subtitle {
  font-size: 30px;
}
</style>
